package cn.itsource.config;

import cn.itsource.system.interceptor.LoginInterceptor;
import cn.itsource.system.interceptor.PermissionInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ItsourceWebmvcConfigurer implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;
    @Autowired
    private PermissionInterceptor permissionInterceptor;

    /**
     * 拦截器注册
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor) //让登录拦截器生效
                .addPathPatterns("/**")
                .excludePathPatterns("/login");

     registry.addInterceptor(permissionInterceptor) //让权限拦截器生效
                .addPathPatterns("/**")
                .excludePathPatterns("/login");

    }
}
